﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CFE
{
	public class URLHelper
	{
		private string rootPath;
		private string[] rootPathPieces;


		public URLHelper(string physicalRootPath)
		{
			rootPath = physicalRootPath;
			rootPathPieces = rootPath.Split('\\');
		}
		

		public string GetPhysicalPath(string virtualPath)
		{
			return Path.Combine(rootPath, virtualPath.Replace('/', '\\'));
		}

		public string GetVirtualPath(string physicalPath)
		{
			string path = physicalPath.Replace(rootPath, "").Replace('\\', '/');
			if (path.StartsWith("/"))
				path = path.Substring(1);
			return path;
		}
	}
}
